
607 P.2d 1154 (1980)
94 N.M. 136
STATE of New Mexico ex rel. Max EDWARDS, Petitioner-Appellant,
v.
The CITY OF CLOVIS, a Municipal Corporation et al., Defendants-Appellees.
No. 12525.
Supreme Court of New Mexico.
March 21, 1980.
*1155 Richard M. Snell, Clovis, for petitioner-appellant.
Harry L. Patton, Clovis, for defendants-appellees.

OPINION
FEDERICI, Justice.
This is an appeal from an adverse judgment by the District Court of Curry County in which the court had granted an alternative writ of mandamus but refused to issue a permanent writ after hearing.
The cause involves the swine ordinances of the City of Clovis. Petitioner maintains his mobile home residence in an addition located within the stockyards area, classified for zoning purposes as the "J Zone" in the City of Clovis. Petitioner's residence was permitted as a variance issued by the City of Clovis in 1977. On March 15, 1979, petitioner filed for a writ of mandamus against the City of Clovis and the members of the City Commission requesting the court to order said parties to enforce the swine ordinances of the City of Clovis and prevent neighbors from maintaining swine within 300 feet of petitioner's residence.
Petitioner contends that maintaining the swine is prohibited by the ordinance of the City of Clovis, particularly Ordinance No. 1006, adopted December 13, 1973. This ordinance prohibits the keeping of swine within the corporate limits of the City of Clovis and amends prior ordinances affecting the "J Zone." Subsequently, on December 6, 1975, the City of Clovis adopted Ordinance No. 1044, prohibiting swine in all zones except the "J Zone." In the "J Zone," swine were permitted but not within 300 feet of any residence.
Petitioner requested the City of Clovis to enforce its ordinance and to prohibit keeping of swine within the 300-foot area. The City refused to grant the petition on the ground that the neighbors had established a nonconforming use prior to the adoption of Ordinance No. 1006, and could therefor continue to maintain swine in the "J Zone" without being restricted to the 300-foot area.
The facts in this case are somewhat complicated. A chronology of events is helpful in determining the issues presented in this appeal:
January 29, 1979: Petitioner requested the City to enforce Ordinance No. 1044.
March 15, 1979: Petition for writ of mandamus was filed in the District Court.
March 29, 1979: A new ordinance was proposed by the City to remove the 300-foot restriction provided for by Ordinance No. 1044.
April 19, 1979: The City of Clovis, by a vote of 4 to 2, passed Ordinance No. 1120-79, amending Section 4-19 of the Clovis City Code, which prohibited swine within 300 feet of a neighboring residence in the "J Zone." The new ordinance permits swine within 300 feet of a neighboring residence.
April 20, 1979: The District Court entered its order denying petitioner's application for a permanent writ of mandamus.
There are four issues on appeal:
(1) Did the trial court err in refusing to apply an ordinance in existence at the time the present case was filed and pending, but which had been amended subsequent to the initiation of such proceeding?
*1156 (2) Did the trial court err in holding that the respondents need not enforce the ordinance since the adjoining owners were entitled to a nonconforming use exemption?
(3) Did the trial court err in concluding that under the circumstances presented to the court in this proceeding it would not be equitable to permit the petitioner to move into an area where swine are kept and then to complain of such land use, which was allegedly previously lawful?
(4) Did the trial court err in concluding that petitioner had shown no clear legal duty to enforce against the neighboring landowners the provisions of Section 4-19[*] of the Clovis City Code?
With reference to Point (1), it is our opinion that a City cannot, by enacting an ordinance, affect or change what would be the result of a pending action before the City Council or Commission or the result of a pending case in court, based upon valid ordinances existing at the time of the application or suit. N.M.Const., Art. IV, §§ 24 and 34. See Marquez v. Wylie, 78 N.M. 544, 434 P.2d 69 (1967); Gray v. Armijo, 70 N.M. 245, 372 P.2d 821 (1962). See also Southwest Underwriters v. Montoya, 80 N.M. 107, 452 P.2d 176 (1969). Article IV, Section 34 of the New Mexico Constitution prohibits the application of any such newly enacted legislation or ordinance so as to affect the outcome of a pending action.
With reference to Point (2), we hold that the trial court erred. The trial court did not reach its final result on the basis of the new ordinance enacted by the City of Clovis. Rather, the trial court rested its decision and final judgment on findings and conclusions, that prior to the time that Ordinance No. 1006 was enacted in 1973, there was no ordinance prohibiting swine within 300 feet of a residence. The trial court reasoned that since there was no probative swine ordinance prior to 1973, persons could keep swine within 300 feet of residences prior to that time and therefore neighbors in the area established a nonconforming use which was binding on petitioner.
A review of the history of the swine ordinances, however, discloses that swine had been prohibited within the City limits of Clovis as early as May 3, 1915, by Ordinance No. 179. The ordinances of the City of Clovis were codified on October 24, 1963, and the substance of Ordinance No. 179 became a part of the new Code as Section 4-19. Section 4-19, as enacted through codification, became the law and swine were prohibited anywhere within the City limits. Application of Dasburg, 45 N.M. 184, 113 P.2d 569 (1941). Thereafter, by Ordinance No. 1006, adopted on December 13, 1973, the City again prohibited the keeping of swine in the City limits. This ordinance was repealed by Ordinance No. 1044, enacted December 6, 1975. Ordinance No. 1044 restricted the presence of swine in all zones in the City except for the "J Zone." In the "J Zone," swine were permitted, but not within 300 feet of a residence. It is this ordinance which petitioner has requested the City to enforce. It is clear from the history of the enactment and codification of the ordinances as set out above, that the keeping of swine was not permitted within the City of Clovis until December 6, 1975, through Ordinance No. 1044, when the keeping of swine was permitted only in the "J Zone" but not within 300 feet of any residence. Prior to 1975, the keeping of swine was not permitted within the City of Clovis by any of its ordinances. Since the keeping of swine was prohibited anywhere in the City of Clovis prior to 1975, neighbors residing in the "J Zone" or elsewhere could not have acquired a nonconforming use. There was no existing zoning ordinance under which such a nonconforming use could have arisen.
With reference to Point (3), the trial court erred in concluding that under the circumstances presented to the court in this proceeding, it would not be equitable to permit petitioner to move into an area where swine are kept and then to complain of such land use, which was allegedly previously *1157 lawful. There was no City ordinance, prior to Ordinance No. 1120-79 (enacted on April 19, 1979), which permitted keeping swine within 300 feet of a residence. Absent a permissive ordinance, the land use made by the neighbors (keeping swine within 300 feet of a residence) was unlawful.
Even if the actions of appellant's neighbors could be deemed a "nonconforming use," the fact that they were unlawful from the beginning would prohibit their continuance. Clovis City Code, Appendix A, Art. XIII (Supp. 1976).
With reference to Point (4), the trial court erred since there was a clear duty on the part of the City to enforce Section 4-19 (as amended by Ordinance No. 1044). Once petitioner showed that there was a valid ordinance in existence and that it was being violated, the duty cast upon the City became ministerial and subject to enforcement by mandamus. El Dorado at Santa Fe, Inc. v. Board of Cty. Com'rs., 89 N.M. 313, 551 P.2d 1360 (1976); Lease v. Board of Regents of New Mexico State Univ., 83 N.M. 781, 498 P.2d 310 (1972); State v. Board of Educ., 18 N.M. 183, 135 P. 96 (1913).
While respondent may not be precluded from enacting ordinances, this does not prohibit petitioner from seeking mandamus against enforcement where the remedies at law available to petitioner are inadequate. Montoya v. Blackhurst, 84 N.M. 91, 500 P.2d 176 (1972); Conklin v. Cunningham, 7 N.M. 445, 38 P. 170 (1894). The fact that petitioner may have available to him other remedies against private individuals does not prevent petitioner from seeking mandamus against respondents. Conklin, supra.
The trial court is reversed and the cause remanded with directions to issue the permanent writ of mandamus against respondents.
IT IS SO ORDERED.
SOSA, C.J., and EASLEY, J., concur.
NOTES
[*]  Both ordinance Nos. 1006 and 1044 are amendments to Section 4-19 of the Clovis City Code. However, for purposes of clarity of amendment they will be referred to by ordinance number.
